﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using Net4.Common.Services;
//using Net4.Common.Entities;
//using System.Workflow.Activities;
//using Net4.Common;

//namespace Net4.Services
//{
//    public class BugService : IBugService
//    {
//        #region IBugService Members

//        public event EventHandler<BugStateChangedEventArgs> BugOpened;

//        public void OpenBug(Guid instanceId, Bug bug)
//        {
//            //if (BugOpened != null)
//            //{
//            //    BugOpened(null, new BugStateChangedEventArgs(id, bug));
//            //}
//            Check.ArgumentIsNotNull(bug, "bug");
//            bool result = RaiseEvent(BugOpened, bug, instanceId);
//        }

//        public event EventHandler<BugStateChangedEventArgs> BugResolved;

//        public void ResolveBug(Guid instanceId, Bug bug)
//        {
//            Check.ArgumentIsNotNull(bug, "bug");
//            if (BugResolved != null)
//            {
//                BugResolved(null, new BugStateChangedEventArgs(instanceId, bug));
//            }
//        }

//        public event EventHandler<BugStateChangedEventArgs> BugClosed;

//        public void CloseBug(Guid instanceId, Bug bug)
//        {
//            Check.ArgumentIsNotNull(bug, "bug");
//            if (BugClosed != null)
//            {
//                BugClosed(null, new BugStateChangedEventArgs(instanceId, bug));
//            }
//        }

//        public event EventHandler<BugStateChangedEventArgs> BugDeferred;

//        public void DeferBug(Guid instanceId, Bug bug)
//        {
//            Check.ArgumentIsNotNull(bug, "bug");
//            if (BugDeferred != null)
//            {
//                BugDeferred(null, new BugStateChangedEventArgs(instanceId, bug));
//            }
//        }

//        public event EventHandler<BugStateChangedEventArgs> BugAssigned;

//        public void AssignBug(Guid instanceId, Bug bug)
//        {
//            Check.ArgumentIsNotNull(bug, "bug");
//            if (BugAssigned != null)
//            {
//                BugAssigned(null, new BugStateChangedEventArgs(instanceId, bug));
//            }
//        }

//        #endregion

//        private bool RaiseEvent(EventHandler<BugStateChangedEventArgs> ev,
//                                Bug bug, Guid instanceId)
//        {
//            bool result = true;
//            try
//            {

//                if (ev != null)
//                {
//                    BugStateChangedEventArgs e = new BugStateChangedEventArgs(instanceId, bug);
//                    ev(null, e);
//                }
//            }
//            catch (EventDeliveryFailedException)
//            {
//                result = false;
//            }

//            return result;
//        }
//    }
//}
